<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view' );


class JAJobBoardViewJAPaymentconfig extends JAView
{
	/**
	 * display method of jl_profile view
	 * @return void
	 **/
	function display($tpml = null)
	{		
		$task = JRequest::getVar('task', '');
		switch ($task){
			case 'edit':
				$this->edit();
				break;
			case 'add':
				$this->setLayout('install');
				break;
			default:
				$this->display_List();
		}		
		
		parent::display($tpml);							
	}	
	
	function display_List()
	{
		global $mainframe;
				
		$lists = $this->get('Vars');
		
		$model = $this->getModel('japaymentconfig');
		$filter_order	= $lists['filter_order'];
		$filter_order_Dir	= $lists['filter_order_Dir']; 
		$limit		= $lists['limit']; 
		$limitstart	= $lists['limitstart']; 
		
		$orderby = '  ORDER BY '. $filter_order .' '. $filter_order_Dir;
		
		$total = $model->total();
		
	    if ($limit > $total) {
	        $limitstart = 0;
	    }
	    $where = '';
	    if(isset($lists['published'])) $where = " where publisded='{$lists['published']}'";
		
	    if( $limit )
			$limited = "  LIMIT ". $limitstart . ','. $limit;
		else $limited = "";
					
		$rows = $model->getTypes($where, $limited, $orderby);
		$rows = $model->check_exist_payment_file($rows);
		
		jimport('joomla.html.pagination');
		$pageNav = new JPagination( $total, $lists['limitstart'], $lists['limit'] );
		
		$this->assignRef('rows', $rows);
		$this->assignRef('lists', $lists);
		$this->assignRef('pageNav', $pageNav);	
			
	}
	function edit()
	{
		global $mainframe, $option;
		
		$row = $this->get('Payment');
		if(!$row) {
			JError::raiseWarning(1, "Payment not found");
			return $this->display_List();
		}
		$this->assignRef('row', $row);		
		
		
		$desk = JPATH_COMPONENT_SITE.DS.'asset'.DS.'payments'.DS.$row->name.'.php';
		require_once($desk);
		$params = new JParameter($row->datas);
		$vars = $params->_registry['_default']['data'];				
		$vars->name = $row->name;
		$vars->alias  = $row->alias;
		$payment = new $row->name($vars);
		$this->assignRef('payment', $payment);		
		$this->assignRef('option', $option);	
	}	
}
?>